# -*- coding: UTF-8 -*-
import direct.actor.Actor as ACTOR
import  game.elements.role.role as GROLE
import panda3d.core as CORE
class Monster(GROLE.GameRole):
    timer_count=0
    timer_last = 0
    def initMonster(self):
        self.ralph = ACTOR.Actor("resource/models/ralph/ralph",
                                 {"run":"resource/models/ralph/ralph-run",
                                  "walk":"resource/models/ralph/ralph-walk"})
        self.ralph.reparentTo(render)
        self.ralph.setScale(.2)
        self.ralph.setPos(self.startPos)

        self.__initRoleCollision__()
    
    def __initRoleCollision__(self):
        self.ralphGroundRay = CORE.CollisionRay()
        self.ralphGroundRay.setOrigin(0,0,1000)
        self.ralphGroundRay.setDirection(0,0,-1)
        self.ralphGroundCol = CORE.CollisionNode('ralphRay')
        self.ralphGroundCol.addSolid(self.ralphGroundRay)
        self.ralphGroundCol.setFromCollideMask(CORE.BitMask32.bit(0))
        self.ralphGroundCol.setIntoCollideMask(CORE.BitMask32.allOff())
        self.ralphGroundColNp = self.ralph.attachNewNode(self.ralphGroundCol)
        self.ralphGroundHandler = CORE.CollisionHandlerQueue()
        self.game_obj.CTrav.addCollider(self.ralphGroundColNp, self.ralphGroundHandler)
    
    def MonsterMove(self,task):
        Monster.timer_count += task.time - Monster.timer_last
        Monster.timer_last = task.time
        self.ralph.setH(self.ralph.getH() + 1)
        if Monster.timer_count >= 360:
            Monster.timer_count = 0
        pass